RUST-2177 Fix WASM compilation failures #521
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
RUST-2177
Boy, it sure would be nice if the ecosystem around WASM would stabilize a bit.
There were
threefivesix things going on here:uuidnow requires thejsfeature when compiled on thewasm32.unknown.unknowntarget (credit to Isabel for finding this one)getrandom0.2.x and 0.3.x (fromahashandrandrespectively); we had a conditional flag set in dev-dependencies for 0.2.x but we didn't have the equivalent (named a different thing -wasm_jsinstead ofjs) for 0.3.x.getrandom0.3.x also requires thatcfg(getrandom_backend=wasm_js)be enabled; normally the way to set customcfgvariables is by setting theRUSTFLAGSenv variable, but for the WASM test program actual compilation is controlled by thewasm-packwrapper scripts which fail to propagate that variable, so we have to set it in.cargo/config.tomlinstead.getrandom(both 0.2.x and 0.3.x) were moved from runtime to compile-time, so the feature additions are now in thebsoncrate in the target-specificdependenciessection rather than being at the binary target/dev-dependencylevel.nodeinstalled on the test host was old enough to have broken behavior, and we were running on old enough hosts that they didn't have new enough glibc (!!) to install current node, so I updated to use newer hosts and installnodelocally for the tests.getrandom0.3.x requires rust >= 1.80 for WASI support, so per our new policy I just bumped the crate MSRV from 1.71.1 up to 1.81 (the most recent version outside of the six month window).